<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        div {
            position: fixed;
            width: 100vw;
            height: 100vh;
            top: 0;
            left: 0;
            background-color: rgba(0, 0, 0, .5);
            display: flex;
            align-items: center;
            justify-content: center;
            display: none;
        }
    </style>
</head>

<body>
    <div>
        <img src="./images/1.gif" alt="">
    </div>
    <button>发送网络请求</button>
    <script src="./js/jquery-1.12.4.js"></script>
    <script>
        $('button').on('click', function () {
            $.ajax({
                url: "http://127.0.0.1:3002/getHeroList",
                success(arr) {
                    console.log(arr);
                },
                // 发送前会调用的函数
                beforeSend() {
                    $('div').css('display', 'flex')
                },
                // 程序出错了 提示用户
                error(err) {
                    console.log('err');
                    alert('请求出错')
                },
                // 不管成功还是失败 都会被调用
                complete() {
                    $('div').hide()
                }
            })
        })
    </script>
</body>

</html>